﻿// JavaScript Document
var oSysMenus = []

var menu_styles = {
						menu:"sysmenuBar",
						menu_table:"sysmenuBarTable",
						menu_td_normal:"normal",
						menu_td_active:"active"
					};				
function SysMenu(menuarr,styles){
	try{
		this.menuarr = menuarr;
		this.styles = styles;
		
		var oMenu;
		var oMenu_table;
		var oMenu_tbody;
		var oMenu_tr = [];
		var oMenu_td = [];
		var oMenu_a = [];
		var oMenu_frm;
		var superthis;
		
		this.createToObj = function(obj){
			oMenu = document.createElement('div');
			if(CommonFunctions._isIE){
				oMenu_frm = document.createElement('iframe');
				oMenu_frm.frameBorder = "no";
				oMenu_frm.marginHeight = 0;
				oMenu_frm.marginWidth = 0;
				oMenu_frm.width = 0;
				oMenu_frm.height = 0;
				oMenu_frm.style.position = "absolute";
				oMenu_frm.style.zIndex = -1;
			}
			oMenu_table = document.createElement('table');
			oMenu_table.cellPadding = 0;
			oMenu_table.cellSpacing = 0;
			oMenu_table.border = 0;
			if(CommonFunctions._isIE) oMenu_table.style.position = "absolute";
			if(CommonFunctions._isIE) oMenu_tbody = document.createElement('tbody');
	
			oMenu.className = this.styles.menu;
			oMenu_table.className = this.styles.menu_table;
			
			
			if(this.menuarr != []){
				for(var i = 0; i < this.menuarr.length; i++){
					oMenu_tr[i] = document.createElement('tr');
					oMenu_td[i] = document.createElement('td');
					oMenu_td[i].id = this.menuarr[i].id;
					oMenu_td[i].className = this.styles.menu_td_normal;
					oMenu_a[i] = document.createElement('a');
					
					oMenu_a[i].innerHTML = this.menuarr[i].name;
					oMenu_a[i].title = this.menuarr[i].title;
					oMenu_a[i].href = this.menuarr[i].href == "" ? "javascript:void(0)" : this.menuarr[i].href;
					oMenu_td[i].appendChild(oMenu_a[i]);
					oMenu_tr[i].appendChild(oMenu_td[i]);
					if(CommonFunctions._isIE) oMenu_tbody.appendChild(oMenu_tr[i]); else oMenu_table.appendChild(oMenu_tr[i]);
				}
				
			}
			
			if(CommonFunctions._isIE) oMenu_table.appendChild(oMenu_tbody);
			oMenu.appendChild(oMenu_table);
			
			if(CommonFunctions._isIE) oMenu.appendChild(oMenu_frm);
			obj.appendChild(oMenu);
			if(CommonFunctions._isIE) oMenu_frm.style.width = oMenu_table.offsetWidth + "px";
			if(CommonFunctions._isIE) oMenu_frm.style.height = oMenu_table.offsetHeight + "px";
			superthis = this;
			this.hide();
			oSysMenus.push(this);
		}
		
		this.show = function(o){
			for(var i = 0; i < oSysMenus.length; i++){
				if(oSysMenus[i].returnObject() != oMenu){
					oSysMenus[i].hide();
				}
			}
			oMenu.style.top = CommonFunctions.getAbsolutePoint(o).t + (o.offsetHeight / 2) + "px";
			oMenu.style.left = CommonFunctions.getAbsolutePoint(o).l + o.offsetWidth + "px";
	
			oMenu.style.display == "none" ? oMenu.style.display = "" : oMenu.style.display = "none";
			var interval = 0;
			oMenu.onmouseover = function(){
				clearTimeout(interval);
			}
			oMenu.onmouseout = function(){
				interval = setTimeout(this.hide,500);
			}.bind(this)
			
		}
		this.hide = function(){
			oMenu.style.display = "none";
		}
		
		this.returnObject = function(){
			return oMenu;
		}
	}catch(e){}
}